<?php
$tm = $_GET['tm'];
$da = json_decode($tm,true);
$data=array('csm'=>"📎 你对ta的了解程度",'dfjs'=>"了解程度：",'df'=>null,'bq1' =>"ta的生日",'bq2'=>"ta喜欢吃的",'bq3'=>"颜色",'bq4'=>"ta的爱好",bq5=>"电影","bq6"=>"整体情况","bq7"=>null,'pf1' =>1,'pf2'=>1,'pf3'=>1,'pf4'=>1,'pf5'=>1,'pf6'=>1);
$df = 0;
for($i=0; $i<5; $i++){
   switch ($i){
       case 0: switch($da[0])
                    {case A: $df=20; $data[pf1]=5;break;
                     case B: $df=0; $data[pf1]=1;break;
                     case C: $df=10; $data[pf1]=3;break;
                     }break;
       case 1:switch($da[1])
                    {case A: $df=$df+20; $data[pf2]=5;break;
                     case B: $df=$df+0; $data[pf2]=1;break;
                     case C: $df=$df+10; $data[pf2]=3;break;
                     }break;
       case 2:switch($da[2])
                    {case A: $df=$df+20;  $data[pf3]=5; break;
                     case B: $df=$df+0;  $data[pf3]=1;break;
                     case C: $df=$df+10;  $data[pf3]=3;break;
                     }break;
       case 3:switch($da[3])
                    {case A: $df=$df+20; $data[pf4]=5;break;
                     case B: $df=$df+0; $data[pf4]=1;break;
                     case C: $df=$df+10; $data[pf4]=3;break;
                     }break;
       case 4:switch($da[4])
                    {case A: $df=$df+20; $data[pf5]=5;break;
                     case B: $df=$df+0; $data[pf5]=1;break;
                     case C: $df=$df+10; $data[pf5]=3;break;
                     }break;
   }
}
if($df>=90){ 
	$data[pf6]=5; }
elseif ($df>=80) {
	$data[pf6]=4;
}
elseif ($df>=60) {
	$data[pf6]=3;
}
elseif ($df>=30) {
	$data[pf6]=2;
}
else{
	$data[pf6]=1;
}
$data[df]=$df.'%';
echo json_encode($data,JSON_UNESCAPED_UNICODE);
$conn = new mysqli('127.0.0.1', '3h74cu729i222', 'gm666946','3h74cu729i222');
$conn ->set_charset("utf8");
$sql = "SELECT * FROM sjtj WHERE num = 0";
$res=$conn->query($sql);
$data=$res->fetch_all();
$sccs=$data[0][5]+1;
$sql = "UPDATE sjtj SET xpzcscs = '$sccs' WHERE num = 0";
$res=$conn->query($sql);
$conn->close();
?>